package com.tulingxueyuan.mbp.component;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;

/**
 * @author :tangweiliang
 * @date : 2023/7/31 21:37
 * 未来的你会感谢现在努力的自己
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        // 插入时：创建时间和修改时间
        this.setFieldValByName("create_Date", new Date(), metaObject);
        this.setFieldValByName("modify_Date", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("modify_Date", new Date(), metaObject);
    }
}
